<?
	include('../classes/clsDB.php');
	
	$r= new ReturnRecord();  // base object for returning data or raw queries
	
	if($_POST['Submit']){
	$SQL="SELECT id,contactName FROM affiliate where username='$_POST[username]' and password='$_POST[password]' LIMIT 0,1";
		$rslt=$r->rawQuery($SQL);
		
		$data=mysql_fetch_array($rslt);
		
		
		if($data[0]>0){ //admin login ok
			session_start();
			$_SESSION["AffKey"]=$data[0];
			$_SESSION["Name"]=$data[1];
			
			header("Location: logged-in/home.php");
		}else{	//admin login bad
			$Message="Incorrect Username or Password";
		};
	};
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Affiliate Bubble Administration Login</title>
<style type="text/css">
body{
	text-align: center;
	background-color: #D6E3F2;
}
td{
	font-family: Arial, Helvetica, sans-serif;
	font-size: 11px;
	text-decoration: none;
}
#loginBox {
	padding: 30px;
	height: 200px;
	width: 450px;
	background-color: #FFFFFF;
	margin-top: 100px;
	margin-right: auto;
	margin-left: auto;
	border: 1px solid #000000;
}
.formButton {
	font-size: 12px;
	color: #FFFFFF;
	background-color: #FF4611;
	border: 1px solid #000000;
	font-weight: bold;
	padding-top: 3px;
	padding-right: 6px;
	padding-bottom: 3px;
	padding-left: 6px;
}
#error{
	font-weight: bold;
	color: #FF0000;
}
</style>
</head>

<body>
<div id="loginBox">
<form name="form1" method="post" action="index.php">
<table border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
  <td colspan="2" align="center"><h2>Affiliates Login </h2></td>
</tr>
<tr>
<td colspan="2" align="center"><div id="error"><?=$Message;?></div></td>
</tr>
<tr>
<td width="62"><strong>Username:</strong></td>
<td width="122"><input type="text" name="username" id="username" class=""></td>
</tr>
<tr>
<td><strong>Password:</strong></td>
<td><input type="password" name="password" id="password"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="Submit" id="Submit" value="Submit" class="formButton"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
